package org.saxion.aktiehuis.view;

import java.util.List;

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JScrollPane;

import org.saxion.aktiehuis.model.Bestelling;
import org.saxion.aktiehuis.services.BestellingManagement;
import javax.swing.JTable;

public class OrderView extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private BestellingManagement bestellingManagement;
	
	private int klantId;
	private List<Bestelling> bestellingen;
	
	private JTable table;
	
	
	/**
	 * Create the panel.
	 */
	public OrderView() {
		
		
		initialize();
	}
	
	private void initialize()
	{
		
		table = new JTable();
		
		add(new JScrollPane(table));
		
	}
	
	public void getOrders()
	{
		System.out.println("Getting orders");
		
		try {
			bestellingen = bestellingManagement.getBestellingKlant(klantId);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		BestellingenTabelModel model = new BestellingenTabelModel(bestellingen);
	    table.setModel(model);
	}
	
	public void setBestellingManagement(BestellingManagement bestellingManagement) throws Exception
	{
		this.bestellingManagement = bestellingManagement;
	}
	
	public void setKlantId(int klantId) {
		this.klantId = klantId;
		
	}

}
